class Solution {
private:
    static constexpr int mod = 1000000007;
public:
    int lengthAfterTransformations(string s, int t) {
        vector<vector<int>> dp(t + 1, vector<int>(26, 0));
        for (int i = 0; i < s.size(); i++) {
            dp[0][s[i] - 'a']++;
        }
        for (int i = 1; i <= t; i++) {
            dp[i][0] = dp[i - 1][25];
            dp[i][1] = (dp[i - 1][25] + dp[i - 1][0]) % mod;
            for (int j = 2; j < 26; j++) {
                dp[i][j] = dp[i - 1][j - 1];
            }
        }
        int ans = 0;
        for (int i = 0; i < 26; i++) {
            ans = (ans + dp[t][i]) % mod;
        }
        return ans;
    }
};
